﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace ExpressionEvaluator.BuilderTreeNode
{
	/// <summary>
	/// Node containing text constant.
	/// </summary>
	internal class TextNode : BuilderTreeNodeBase
	{
		/// <summary>
		/// Gets the expression.
		/// </summary>
		/// <param name="tree">The tree.</param>
		/// <returns>Expression value of this node.</returns>
		public override Expression GetExpression(BuilderTree tree)
		{
			return Expression.Constant(Idents[0].Text);
		}

		/// <summary>
		/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </summary>
		/// <returns>
		/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </returns>
		public override string ToString()
		{
			return "\"" + Idents[0].Text + "\"";
		}
	}
}
